package com.sky.context;

import java.util.HashMap;
import java.util.Map;

public class BaseContext {

    public static ThreadLocal<Map<String,Long>> threadLocal = new ThreadLocal<>();

    public static void setCurrentEmpId(Long id) {
        Map<String,Long> map1 = threadLocal.get();
        if (map1 == null){
            map1 = new HashMap<>();
            map1.put("empId",id);
            threadLocal.set(map1);
        }else {
            map1.put("empId",id);
        }
        //threadLocal.set(id);
    }

    public static void setCurrentUserId(Long id){
        Map<String ,Long> map = threadLocal.get();
        if (map == null){
            map = new HashMap<>();
            map.put("userid",id);
            threadLocal.set(map);
        }else {
            map.put("userid",id);
        }
    }
    public static Long getCurrentEmpId() {
        return threadLocal.get().get("empId");
    }
    public static Long getCurrentUserId(){
        return threadLocal.get().get("userid");
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }

}
